home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / compre1a / runthrou.frm (.txt) < prev   
Encoding:
Visual Basic Form  |  1999-08-31  |  4.3 KB  |  120 lines

  1. VERSION 5.00
  2. Object = "{F5BE8BC2-7DE6-11D0-91FE-00C04FD701A5}#2.0#0"; "AGENTCTL.DLL"
  3. Begin VB.Form frmScript 
  4.    Caption         =   "Running through a set script"
  5.    ClientHeight    =   1635
  6.    ClientLeft      =   60
  7.    ClientTop       =   345
  8.    ClientWidth     =   4680
  9.    LinkTopic       =   "Form1"
  10.    ScaleHeight     =   1635
  11.    ScaleWidth      =   4680
  12.    StartUpPosition =   3  'Windows Default
  13.    Begin VB.Label Label1 
  14.       Height          =   315
  15.       Left            =   420
  16.       TabIndex        =   0
  17.       Top             =   1020
  18.       Width           =   3495
  19.    End
  20.    Begin AgentObjectsCtl.Agent Agent 
  21.       Left            =   360
  22.       Top             =   300
  23.       _cx             =   847
  24.       _cy             =   847
  25.    End
  26. Attribute VB_Name = "frmScript"
  27. Attribute VB_GlobalNameSpace = False
  28. Attribute VB_Creatable = False
  29. Attribute VB_PredeclaredId = True
  30. Attribute VB_Exposed = False
  31. Option Explicit
  32. Dim Genie As IAgentCtlCharacter
  33. Dim Merlin As IAgentCtlCharacter
  34. Dim LoadRequest(3)
  35. Dim GenieRequest As IAgentCtlRequest
  36. Dim MerlinRequest As IAgentCtlRequest
  37. Private Sub Agent_RequestComplete(ByVal Request As Object)
  38.     Select Case Request
  39.         Case LoadRequest(1)
  40.             If Request.Status <> 0 Then
  41.                 ' If genie's character data fails to load post a message
  42.                 Label1.Caption = "Genie character failed to load."
  43.                 MsgBox "Unable to load the Genie character. Program will terminate"
  44.                 Unload Me
  45.             Else
  46.                 Label1.Caption = "Genie character successfully loaded."
  47.                 'Create a reference to the character
  48.                 Set Genie = Agent.Characters("Genie")
  49.                 Call GenieIntro
  50.             End If
  51.         Case LoadRequest(2)
  52.             If Request.Status <> 0 Then
  53.                 Label1.Caption = "Merlin character failed to load."
  54.                 Genie.Speak "Uh oh, Merlin failed to load."
  55.                 Genie.Speak "You'll have to exit!"
  56.                 Genie.Hide
  57.             Else
  58.                 Label1.Caption = "Merlin character successfully loaded."
  59.                 Set Merlin = Agent.Characters("Merlin")
  60.                 Call MerlinIntro
  61.             End If
  62.         Case LoadRequest(3)
  63.             Unload Me
  64.     End Select
  65. End Sub
  66. Private Sub LoadGenie()
  67.     Set LoadRequest(1) = Agent.Characters.Load("Genie", "Genie.acs")
  68.     Label1.Caption = "Loading Genie character."
  69. End Sub
  70. Private Sub LoadMerlin()
  71.     Set LoadRequest(2) = Agent.Characters.Load("Merlin", "Merlin.acs")
  72.     Label1.Caption = "Loading Merlin character."
  73. End Sub
  74. Private Sub GenieIntro()
  75.     Genie.MoveTo 170, 240
  76.     Genie.Show
  77.     Genie.Speak "Hello!  I am Genie, a Microsoft Agent Character"
  78.     Genie.Play "Greet"
  79.     Genie.Speak "and I am at your service"
  80.     Genie.Play "Blink"
  81.     Genie.Speak "I hope Geeza's code will help you to create Agent scripts easily too, and get around the problem that we can't pronounce Geeza correctly.  \pau=200\G-eeza, \pau=200\GG eeza..."
  82.     Call LoadMerlin
  83.     Set GenieRequest = Genie.Speak("But for now, here's Merlin!")
  84.     Genie.Play "LookLeft"
  85. End Sub
  86. Private Sub MerlinIntro()
  87.     Merlin.MoveTo 320, 240
  88.     Merlin.Wait GenieRequest
  89.     Merlin.Show
  90.     Merlin.Play "Wave"
  91.     Merlin.Speak "Hello to you all.  I am Merlin; another Microsoft Agent Character"
  92.     Merlin.Play "Blink"
  93.     Call Routine1
  94. End Sub
  95. Private Sub Routine1()
  96.     Genie.Play "Blink"
  97.     Call Time_For_Tubbie_Bye_Byes
  98. End Sub
  99. Private Sub Time_For_Tubbie_Bye_Byes()
  100.     Merlin.Wait GenieRequest
  101.     Set MerlinRequest = Merlin.Speak("So it's goodbye from me,")
  102.     Genie.Wait MerlinRequest
  103.     Set GenieRequest = Genie.Speak("And it's goodbye from him")
  104.     Merlin.Wait GenieRequest
  105.     Set MerlinRequest = Merlin.Speak("Goodnight")
  106.     Genie.Wait MerlinRequest  'I had to do it, sorry!
  107.     Genie.Hide                'The Two Ronnie's rocked :)
  108.     Set LoadRequest(3) = Merlin.Hide
  109. End Sub
  110. Private Sub Form_Load()
  111.     Call LoadGenie
  112. End Sub
  113. 'This is a very much earlier version of the other script,
  114. 'but it shows how to make a continuous script for the
  115. 'Agents, without the dreaded
  116. '"Variable without Block variable set" or whatever it is,
  117. 'enjoy!
  118. 'GEEZA
  119. 'Off to the land of Dreams ~~~~~~~~~~~~~~
  120.